package jym.tan.movielibrary.component.ui.combobox;

import javax.swing.DefaultComboBoxModel;

import jym.tan.movielibrary.component.base.BaseComboBox;
import jym.tan.movielibrary.component.ui.combobox.model.ThemeComboBoxModel;
import jym.tan.movielibrary.configuration.ConfigurationManager;
import jym.tan.movielibrary.factory.ListenerFactory;
import jym.tan.movielibrary.model.ThemeModel;

public class ThemeComboBox extends BaseComboBox<ThemeComboBox> {

	private static final long serialVersionUID = 50L;

	public ThemeComboBox(DefaultComboBoxModel model) {
		super(model);
	}
	
	@Override
	public void initialize() {
		ThemeComboBoxModel model = (ThemeComboBoxModel) getModel();
		int index = 0;
		for(ThemeModel themeModel : model.getThemeModels()) {
			if(themeModel.equals(ConfigurationManager.getInstance().getConfiguration().getUiManager().getUiProperties().getThemeModel())) {
				setSelectedIndex(index);
				break;
			}
			index++;
		}
		
		addActionListener(ListenerFactory.getThemeComboBoxListener());
	}
}
